package com.yc.test.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * @Date: 2018/11/30 19:19
 * @Author: Can.Yang
 * @Description:
 */
@SuppressWarnings("unchecked")
@Component
public class RedisHelper {

    @Autowired
    private RedisTemplate redisTemplate;


    /**
     * 判断缓存中是否有对应的value
     */
    public boolean existsKey(String key) {
        return redisTemplate.hasKey(key);
    }

    /**
     * 重名名key，如果newKey已经存在，则newKey的原值被覆盖
     */
    public void renameKey(String oldKey, String newKey) {
        redisTemplate.rename(oldKey, newKey);
    }

}
